package com.test39_集合应用.vo;

import java.io.Serializable;

/**
 * 学生类
 */
public class Student implements Serializable, Comparable<Student> {
    private String name;
    private Integer age;
    private Double math;    // 数学成绩
    private Double program; // 编程成绩
    private Double english; // 英语成绩

    public Student() {
    }

    public Student(String name, Integer age, Double math, Double program, Double english) {
        this.name = name;
        this.age = age;
        this.math = math;
        this.program = program;
        this.english = english;
    }

    @Override
    public int compareTo(Student o) {
        if ((this.math + this.program + this.english) > (o.math + o.program + o.english)) {
            return -1;
        } else if ((this.math + this.program + this.english) < (o.math + o.program + o.english)) {
            return 1;
        } else {
            return this.age - o.age;
        }
    }

    @Override
    public String toString() {
        return "【Student】姓名：" + this.name + "、年龄：" + this.age
                + "、数学成绩：" + this.math + "、编程成绩：" + this.program + "、英语成绩：" + this.english;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Double getMath() {
        return math;
    }

    public void setMath(Double math) {
        this.math = math;
    }

    public Double getProgram() {
        return program;
    }

    public void setProgram(Double program) {
        this.program = program;
    }

    public Double getEnglish() {
        return english;
    }

    public void setEnglish(Double english) {
        this.english = english;
    }
}
